package com.weblog.weblog.admin.controller;

import com.weblog.weblog.admin.service.AdminFileService;
import com.weblog.weblog.common.aspect.ApiOperationLog;
import com.weblog.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author gc
 * @date 2023年10月07日 21:24
 */

@RestController
@RequestMapping("/admin")
@Api(tags = "Admin 文件模块")
public class AdminFileController {
    @Autowired
    private AdminFileService fileService;

    @ApiOperation(value = "文件上传" )
    @PostMapping("/file/upload")
    @ApiOperationLog(description = "文件上传")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Response uploadFile(@RequestParam MultipartFile file){
        return fileService.uploadFile(file);
    }
}
